from pydantic import BaseModel, EmailStr
from datetime import date
from typing import Optional

class StudentBase(BaseModel):
    name: str
    email: EmailStr
    major: str
    date_of_birth: date
    year: int

class StudentCreate(StudentBase):
    pass

class StudentUpdate(BaseModel):
    name: Optional[str] = None
    email: Optional[EmailStr] = None
    major: Optional[str] = None
    date_of_birth: Optional[date] = None
    year: Optional[int] = None

class Student(StudentBase):
    id: int

    class Config:
        orm_mode = True